// 封装与文章相关的操作

import axios from '@/utils/request'
// 获取文章列表
export const getArticles = (channelId, timestamp) => {
  return axios({
    url: '/app/v1_1/articles',
    method: 'GET',
    params: {
      channel_id: channelId,
      timestamp: timestamp,
      with_top: 0
    }
  })
}
// 不感兴趣
export const dislikeActicle = (articleId) => {
  return axios({
    url: '/app/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: articleId
    }
  })
}
// 举报文章
export const reportArticle = (articleId, typeId) => {
  return axios({
    method: 'POST',
    url: '/app/v1_0/article/reports',
    data: {
      target: articleId,
      type: typeId
    }
  })
}

// 根据文章编号获取文章详情
export const getArticle = id => {
  return axios({
    url: '/app/v1_0/articles/' + id,
    method: 'GET'
  })
}

/**
 * 取消点赞
 * @param {*} id 文章编号
 */
export const deleteLike = id => {
  return axios({
    method: 'DELETE',
    url: '/app/v1_0/article/likings/' + id
  })
}

/**
 * 添加点赞
 * @param {*} id 文章编号
 */
export const addLike = id => {
  return axios({
    method: 'POST',
    url: '/app/v1_0/article/likings',
    data: {
      target: id
    }
  })
}

/**
 * 取消不喜欢
 * @param {*} id 文章编号
 */
export const deleteDisLike = id => {
  return axios({
    method: 'DELETE',
    url: '/app/v1_0/article/dislikes/' + id
  })
}

/**
 * 添加不喜欢
 * @param {*} id 文章编号
 */
export const addDisLike = id => {
  return axios({
    method: 'POST',
    url: '/app/v1_0/article/dislikes',
    data: {
      target: id
    }
  })
}
